package com.bhs.sansonglogistics.ui.adapter;

import android.text.Html;
import android.text.Spanned;
import android.text.TextUtils;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bhs.sansonglogistics.R;
import com.bhs.sansonglogistics.bean.CollaborationBean;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

public class AddEnterpriseAdapter extends BaseQuickAdapter<CollaborationBean, BaseViewHolder> {


    public AddEnterpriseAdapter() {
        super(R.layout.item_collaboration);

    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, CollaborationBean item) {
        Glide.with(mContext).load(item.getCompany_pic()).into((ImageView) helper.getView(R.id.iv_image));
        helper.setText(R.id.tv_company_name, item.getCompany_name());
        if (item.getLine_info().getStart_city() != null) {
            String start_city = item.getLine_info().getStart_city().replace("市", "");
            helper.setText(R.id.tv_start_city, start_city);
            String end_city = item.getLine_info().getEnd_city().replace("市", "");
            helper.setText(R.id.tv_end_city, end_city);
        }
        helper.setVisible(R.id.rl_line, item.getLine_info().getStart_city() != null);
        helper.setText(R.id.tv_address, item.getAddress());
        // helper.setText(R.id.tv_distance, String.format("%skm", item.getDistance()));
        Spanned PageView = Html.fromHtml("浏览量:<font color=\"#000000\">" + item.getVisitor_count() + "</font>");
        helper.setText(R.id.tv_page_view, PageView);
        Spanned OrderQuantity = Html.fromHtml("下单量:<font color=\"#000000\">" + item.getOrder_count() + "</font>");
        helper.setText(R.id.tv_order_quantity, OrderQuantity);
        Spanned QuantityCollection = Html.fromHtml("收藏量:<font color=\"#000000\">" + item.getCollect_count() + "</font>");
        helper.setText(R.id.tv_quantity_collection, QuantityCollection);
        helper.setText(R.id.tv_announcement, item.getPublic_notice());
        helper.setGone(R.id.tv_announcement, !TextUtils.isEmpty(item.getPublic_notice()));
        helper.setText(R.id.tv_consent, "立即添加");
        helper.setGone(R.id.tv_refuse, false);
        helper.setVisible(R.id.tv_hint, false);
        helper.addOnClickListener(R.id.tv_consent).addOnClickListener(R.id.ll_contact);

    }
}
